/**
 * @description 微博 @ 关系 controller
 * @author 刘煎蛋
 */

const { getAtUserBlogList, getAtRelationCount } = require('../services/at-relation');
const { PAGE_SIZE } = require('../conf/constant');
const { SuccessModel } = require('../model/ResModel');

/**
  * 获取 @ 用户的微博列表
  * @param {*} userId 用户id
  * @param {*} pageIndex 分页
  */
async function getAtMeBlogList( userId, pageIndex ) {
    const result = await getAtUserBlogList({
        userId,
        pageIndex,
        pageSize: PAGE_SIZE
    })
    const { count, blogList } = result;

    return new SuccessModel({
        isEmpty: blogList.length == 0,
        blogList,
        pageSize: PAGE_SIZE,
        pageIndex,
        count
    })
}

/**
 * 获取 @ 我的微博数量
 * @param {*} userId 
 */
async function getAtMeCount( userId ) {
    const count = await getAtRelationCount( userId );
    return new SuccessModel({
        count
    })
}

module.exports = {
    getAtMeBlogList,
    getAtMeCount
}